package cn.lysj.framework.store.controller;

import cn.lysj.framework.base.BaseController;
import cn.lysj.framework.common.annotation.CurrentUser;
import cn.lysj.framework.common.domain.User;
import cn.lysj.framework.common.utils.pagination.PageVo;
import cn.lysj.framework.common.utils.web.Resp;
import cn.lysj.framework.common.validate.annotation.Validator;
import cn.lysj.framework.store.domain.EatTable;
import cn.lysj.framework.store.service.EatTableService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author drj
 * @description 餐桌控制层
 * @create 2018-11-02 10:15:54
 **/
@Slf4j
@RestController
@Api(description = "餐桌管理接口")
@RequestMapping("/eat_table")
public class EatTableController extends BaseController<EatTable> {

    @Resource
    private EatTableService eatTableService;

    @Override
    public EatTableService getService() {
        return eatTableService;
    }

    @Override
    public Resp save(@Validator EatTable eatTable) {
        return null;
    }

    @PostMapping("/save_rewrite")
    public Resp save(@CurrentUser User user,@Validator EatTable eatTable){
        eatTable.setStoreId(user.getStoreId());
        eatTable.setUpdateTime(new Date());
        return eatTableService.saveRewrite(eatTable);
    }

    @Override
    public Resp list(EatTable eatTable, PageVo pageVo){
        return null;
    }

    @GetMapping("/list_rewrite")
    public Resp list(@CurrentUser User user, EatTable eatTable, PageVo pageVo){

        eatTable.setStoreId(user.getStoreId());
        return new Resp(eatTableService.list(eatTable,pageVo));
    }

}
